home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
printing
/
hc24_h12.arc
/
HC24_H12.C
next >
Wrap
C/C++ Source or Header
|
1992-02-15
|
7KB
|
215 lines
> The 2 files listings follows:
> Beginning of file HC24_H12.H
/* The prototypes */
extern void outchar (int c);
extern void outchars (char *str);
> End of file HC24_H12.H
> Beginning of file HC24_H12.C
/*
* HC24_H12.C Version Horizontal 1.1: For a hard-copy on a BROTHER M-1224L
* 24 pins printer. (LQ500 compatible). It replaces the 9 pin hard-copy
* internal (ROM) routine. To be put in the \AUTO folder. This one in
* horizontal and respects the x/y ratio. Twice the linear size of
* HC24_H10, good blacks, the best up now, but needs a 128k spooler.
* R.Hoh 02/01/92
* Modified 7/2/92 by Ulf RIMKUS (RIMKUS_U@DMRHRZ11.BITNET) for Turbo-C
* Recompiled 7/2/92 by Ulf RIMKUS with Turbo-C
*/
#if defined(__PUREC__)
#include <tos.h>
#include <setjmp.h>
#include <stdio.h>
#include "HC24_H12.h" /* Protypes */
#define BC_PRT 0
#define BP _BasPag
#define DUMP_VEC ((long **)0x502) /* hard-copy vector */
#else
#include <basepage.h>
#include <osbind.h>
#include <bios.h>
#include <xbios.h>
#include <setjmp.h>
#include <types.h> /* for size_t type */
#define DUMP_VEC ((long *)0x502) /* hard-copy vector */
#endif
#define N_BYTES 128000L /* # of data bytes to be sent */
#if defined (__PUREC__)
void * pokel (long **address, size_t value);
#else
extern long pokel ();
/*
* MUST be declared with MWC, even if pokeing
* is intended to return nothing...
*/
#endif
/* macro for peekb in supervisor mode */
#define peekbyte(cp) (*((char *)cp))
jmp_buf env; /* MUST be global */
/*************************************************
* outputs a char to the printer port (if ready) *
*************************************************/
void outchar (c)
int c; /* Yes, I know, but needed by Bconout()... */
{
long ii = N_BYTES; /* as many as data bytes to be sent */
do {
if (Bcostat (BC_PRT)) {
Bconout (BC_PRT, c);
return;
}
} while (ii--);
longjmp (env, 1); /* exit : printer/spooler not ready */
}
/********************************************************
* outputs a message to the printer port: *
* the 1st byte contains the length of the message *
* This is needed 'cause some '\0' may have to be sent *
********************************************************/
void outchars (str)
char *str;
{
register i;
for (i = 1; i < str[0]; i++)
outchar (str[i]);
}
/*********************
* hard-copy routine *
*********************/
void hard_copy () {
static char init_prt[] = {
10, /* # of chars */
27, '@', /* Reset printer */
27, 'l', 5, /* Left margin */
27, 'A', 8, /* define new vertical * space */
10 /* LF */
};
static char line_init[] = {
6, /* # of chars */
27, '*', /* Binary mode... */
39, /* ...1440 dots/line */
0, /* # of data = (2 * 640) % 256 */
5 /* # of data = (2 * 640) / 256 */
};
static char next_line[] = {
3, /* # of chars */
13, /* CR */
10 /* LF */
};
static char reset_prt[] = {
3, /* # of chars */
27, '@' /* Reset printer */
};
static char *screen_base;
static char masks[] = {
128, 64, 32, 16, 8, 4, 2, 1
};
static char mask2[] = {
128 + 64, 32 + 16, 8 + 4, 2 + 1
};
static char dat[3];
register char *pos, data, mask;
register unsigned i, drow, col;
int prow;
/*** Here comes the hard-copy algo. itself ***/
if (setjmp (env) == 0) {
outchars (init_prt);
screen_base = Physbase ();
for (prow = 0; prow < 33; prow++) {/* printer rows */
outchars (line_init);
for (col = 0; col < 640; col++) {
mask = masks[col % 8];
pos = screen_base + (prow * 3 * 4 * 80) + (col / 8);
for (drow = 0; drow < 3; drow++) {/* data rows */
data = 0; /* clear data */
for (i = 0; i < 4; i++) {
/* pixel = (mask & (peekbyte (pos+(drow * 80 * 4)+(i * 80)))) */
if (mask & (peekbyte (pos+(drow * 80 * 4)+(i * 80))))
data |= mask2[i];
}
outchar (data);
dat[drow] = data;
}
for (drow = 0; drow < 3; drow++)/* 2nd data row */
outchar (dat[drow]);
}
outchars (next_line);/* on the printer */
}
/*
* for last printer row, special treatment 'cause
* there are only 4 screen pixels height to process.
*/
outchars (line_init);
for (col = 0; col < 640; col++) {
mask = masks[col % 8];
pos = screen_base + (prow * 3 * 4 * 80) + (col / 8);
data = 0;
for (i = 0; i < 4; i++) {
if (mask & (peekbyte (pos + (i * 80))))
data |= mask2[i];
}
outchar (data);
outchar (0);
outchar (0);
outchar (data);
outchar (0);
outchar (0);
}
outchars (reset_prt);
}
}
/****************************************
*** Here we modify the screen-dump ***
*** vector and let the code residant ***
****************************************/
main () {
pokel (DUMP_VEC, (size_t) hard_copy);/* Modify hc vector */
Cconws ("\r\n \033p"); /* reverse video ON */
Cconws ("LQ500 compatible hard-copy routine installed.");
Cconws ("\033q\r\n "); /* reverse video OFF */
Cconws ("Version H1.2 by hohr@cernvax.cern.ch.\r\n");
/*
* Terminate and Stay Resident, so the buffers we
* assigned do not get clobbered by the next process.
*/
Ptermres ((long) BP -> p_hitpa - (long) BP -> p_lowtpa, 0);
return 0; /* That PureC is satisfied */
}
#if defined(__PUREC__)
void * pokel (long **address, size_t value) {
long oldstack;
void * old_vec;
oldstack = Super (0L);
old_vec = *address;
*address = (void *) value;
Super ((void *) oldstack);
return (old_vec);
}
#endif
> End of file HC24_H12.C